package com.yunzhu.yunzhubookingservice.config;

import com.yunzhu.yunzhubookingservice.interceptor.AccessLogInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    //设置排除路径，spring boot 2.*,注意排除掉静态资源的路径，不然静态资源无法访问
    private final String[] excludePath ={"/static/**","/error"};

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AccessLogInterceptor()) //注册AccessLogInterceptor拦截器
                .addPathPatterns("/**").excludePathPatterns(excludePath);
    }
}
